<template>
  <div class="log-root">
    <van-sticky>
      <van-nav-bar title="日志" />
    </van-sticky>

    <div class="list-box">
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          :offset="50"
          @load="onLoad"
        >
          <div class="item flex" v-for="(item, index) in lists" :key="index">
            <img v-if="item.type == 8||item.type == 13||item.type == 14||item.type == 15" 
						src="@/assets/images/log/error.png" alt="" />
            <img
              v-if="item.type == 6||item.type == 7||item.type == 10||item.type == 12"
              src="@/assets/images/log/sell.png"
              alt=""
            />
						<img
						  v-if="item.type == 5"
						  src="@/assets/images/log/up.png"
						  alt=""
						/>
						<img
						  v-if="item.type == 2"
						  src="@/assets/images/log/down.png"
						  alt=""
						/>
            <img v-if="item.type == 1||item.type == 3||item.type == 4||item.type == 9 ||item.type == 11" src="@/assets/images/log/buy.png" alt="" />
            <div class="name-box">
              <div class="top">
                <!-- <div class="name">
                  <div class="flex">
                    <div>{{item.coin_name}}</div>
                    <div style="font-size: 0.2rem"></div>
                  </div>
                  <div class="code">usdt</div>
                </div> -->

                <div class="state">
                  {{ item.message }}
                </div>
              </div>

              <div class="time">{{ item.create_time }}</div>
            </div>
          </div>
        </van-list>
      </van-pull-refresh>
    </div>
  </div>
</template>

<script>
import mixin from "@/mixin.js";
import { Toast } from "vant";
import { RULE_TIPS } from "@/api/api.js";
export default {
  data() {
    return {
      lists: [],
      loading: false,
      finished: false,
      refreshing: false,
      page: 1,
    };
  },

  methods: {
    async getList() {
      const { data } = await this.$reqGet(RULE_TIPS, {
        page: this.page,
      });
      if (data.status == 1) {
        this.lists = data.data.list;
        this.loading = false;
        this.finished = data.data.list.length > 0 ? false : true;
        this.page++;
      }
    },
    async LoadList() {
      this.loading = true;
      const { data } = await this.$reqGet(RULE_TIPS, {
        page: this.page,
      });
      console.log(data.data.list);
      if (data.status == 1 && data.data.list.length > 0) {
        let list = data.data.list;
        this.lists = this.lists.concat(list);
        this.loading = false;
        this.page++;
      } else {
        console.log("没有了");
        this.finished = true;
      }
    },
    onLoad() {
      this.loading = false;
      this.LoadList();
    },
    onRefresh() {
      this.page = 1;
      this.lists = [];
      // 清空列表数据
      this.refreshing = false;
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
  },
};
</script>

<style lang="scss" scoped>
.log-root {
  background-color: #fff;
  color: #141414;
  font-size: 0.26rem;
  height: 100vh;

  .list-box {
    background-color: #fff;

    .item {
      padding: 0.3rem;
      border-bottom: 0.02rem solid #f0eeee;

      img {
        width: 0.38rem;
        height: 0.38rem;
        margin-right: 0.23rem;
      }
      .name-box {
        .top {
          display: flex;
          align-items: flex-start;
          margin-bottom: 0.15rem;
          .name {
            .flex {
              align-items: flex-end;
              margin-bottom: 0.1rem;
            }
            .code {
              text-align: left;
              font-size: 0.2rem;
            }
          }

          .state {
            font-size: 0.2rem;
            // margin-left: 0.27rem;
            line-height: 0.36rem;
            text-align: left;
          }
        }

        .time {
          text-align: left;
          font-size: 0.2rem;
          color: #a1a1a1;
        }
      }
    }
  }
}
</style>
